<!-- 仓库管理页面 -->
<template>
  <div class="supplierMessage">
    <!-- 搜索仓库部分 -->
    <el-card class="searchCard" shadow="never" :body-style="{ padding: '20px' }">
      <div slot="header">
        <span>仓库管理</span>
      </div>
      <el-form ref="searchForm" class="searchForm" :model="searchForm" label-width="100px" :inline="false" size="normal">
        <el-form-item label="仓库名称:">
          <el-input v-model="searchForm.warehouseName" style="width:200px" placeholder="仓库名称" size="small" clearable />
        </el-form-item>
        <el-form-item>
          <el-button type="default" size="small">重置</el-button>
          <el-button type="primary" size="small">查询</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <!-- 仓库列表卡片 -->
    <el-card class="supplierList" shadow="never" :body-style="{ padding: '20px' }">
      <div slot="header">
        <span>仓库列表</span>
        <el-button type="primary" style="width:80px;margin-left:20px" size="small" @click="addWarehouse">+添加</el-button>
      </div>
      <template>
        <!-- 仓库列表 -->
        <el-table
          :data="tableData"
          style="width: 100%"
          border
          :header-cell-style="{textAlign: 'center'}"
          :cell-style="{ textAlign: 'center' }"
        >
          <el-table-column
            prop="num"
            label="序号"
            width="200"
          />
          <el-table-column
            prop="warehouseName"
            label="仓库名称"
            width="200"
          />
          <el-table-column
            prop="staff"
            label="负责人"
            width="200"
          />
          <el-table-column
            prop="telephone"
            label="联系电话"
          />
          <el-table-column
            prop="contactPlace"
            label="联系地址"
          />
          <el-table-column
            prop="remarks"
            label="备注"
          />
          <el-table-column
            label="操作"
            width="400"
          >
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="editWarehouse(scope.row)">编辑</el-button>
              <el-button type="text" size="small" @click="deleteWarehouse">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!-- 添加仓库弹框 -->
        <el-dialog
          title="仓库信息"
          :visible.sync="dialogVisible"
          width="40%"
          style="margin-top:120px;"
          class="dialog"
        >
          <div class="addWarehouse">
            <!-- 添加虚拟仓弹框 -->
            <el-form ref="addForm" class="addForm" :model="addForm" label-width="100px" :inline="false" size="normal">
              <el-form-item label="仓库名称:">
                <el-input v-model="addForm.warehouseName" style="width:400px" placeholder="仓库名称" size="small" clearable />
              </el-form-item>
              <el-form-item label="负责人:">
                <el-input v-model="addForm.staff" style="width:400px" placeholder="负责人" size="small" clearable />
              </el-form-item>
              <el-form-item label="联系电话:">
                <el-input v-model="addForm.telephone" style="width:400px" placeholder="联系电话" size="small" clearable />
              </el-form-item>
              <el-form-item label="联系地址:">
                <el-input v-model="addForm.contactPlace" style="width:400px" placeholder="联系地址" size="small" clearable />
              </el-form-item>
              <el-form-item label="备注:">
                <el-input v-model="addForm.remarks" style="width:400px" placeholder="30字以内" type="textarea" maxlength="30" size="small" show-word-limit :rows="2" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" style="width:100px;height:40px" size="small">提交</el-button>
                <el-button type="default" style="width:100px;height:40px" size="small">取消</el-button>
              </el-form-item>
            </el-form>
          </div>
        </el-dialog>
        <!-- 编辑虚拟仓弹框 -->
        <el-dialog
          title="仓库信息"
          :visible.sync="showEditWarehouse"
          width="40%"
          style="margin-top:120px;"
          class="dialog"
        >
          <div class="addWarehouse">
            <!-- 编辑虚拟仓弹框表单 -->
            <el-form ref="editWarehouseForm" class="addForm" :model="editWarehouseForm" label-width="100px" :inline="false" size="normal">
              <el-form-item label="仓库名称:">
                <el-input v-model="editWarehouseForm.warehouseName" style="width:400px" placeholder="仓库名称" size="small" clearable />
              </el-form-item>
              <el-form-item label="负责人:">
                <el-input v-model="editWarehouseForm.staff" style="width:400px" placeholder="负责人" size="small" clearable />
              </el-form-item>
              <el-form-item label="联系电话:">
                <el-input v-model="editWarehouseForm.telephone" style="width:400px" placeholder="联系电话" size="small" clearable />
              </el-form-item>
              <el-form-item label="联系地址:">
                <el-input v-model="editWarehouseForm.contactPlace" style="width:400px" placeholder="联系地址" size="small" clearable />
              </el-form-item>
              <el-form-item label="备注:">
                <el-input v-model="editWarehouseForm.remarks" style="width:400px" placeholder="30字以内" type="textarea" maxlength="30" size="small" show-word-limit :rows="2" />
              </el-form-item>
              <el-form-item>
                <el-button type="primary" style="width:100px;height:40px" size="small">提交</el-button>
                <el-button type="default" style="width:100px;height:40px" size="small">取消</el-button>
              </el-form-item>
            </el-form>
          </div>
        </el-dialog>
        <div class="block">
          <!-- 消息表格分页器 -->
          <el-pagination
            :current-page="currentPage4"
            :page-sizes="[100, 200, 300, 400]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="400"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </template>
    </el-card>
  </div>
</template>

<script>
export default {
// import引入的组件需要注入到对象中才能使用，
  components: {},
  data() {
    // 这里存放数据
    return {
      editWarehouseForm: { // 编辑虚拟框信息

      },
      showEditWarehouse: false,
      addForm: { // 添加仓库数据
        warehouseName: '',
        staff: '',
        telephone: '',
        contactPlace: '',
        remarks: ''
      },
      dialogVisible: false,
      searchForm: {
        warehouseName: '' // 仓库名称
      },
      tableData: [{
        num: 1,
        warehouseName: '服务仓',
        staff: '张三',
        telephone: '17312341234',
        contactPlace: '浙江省杭州市',
        remarks: '17311111111'
      }, {
        num: 1,
        warehouseName: '服务仓',
        staff: '张三',
        telephone: '17312341234',
        contactPlace: '浙江省杭州市',
        remarks: '17311111111'
      }],
      currentPage4: 2 // 当前页数
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {

  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {

  },
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {},
  // 方法集合
  methods: {
    deleteWarehouse() {
      console.log('删除仓库')
    },
    editWarehouse(el) { // 编辑虚拟框信息
      this.showEditWarehouse = true
      this.editWarehouseForm = el
      console.log(this.editWarehouseForm)
    },
    addWarehouse() { // 跳转到添加供应方页面
      this.dialogVisible = true
    },
    handleSizeChange(val) { // 分页器事件每页条数
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) { // 分页器事件当前页
      console.log(`当前页: ${val}`)
    }
  } // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style scoped lang="scss">
.supplierMessage{
   width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #f0f2f5;
    .searchCard{
      margin: 30px;
      .searchForm{//搜索表单样式
        display: flex;
      }
    }
    .supplierList{//供应商列表
      margin: 30px;
    }
    .addWarehouse{
      display: flex;
      justify-content: space-around;
    }
    .block{//分页器样式
      margin-top: 20px;
        padding: 20px;
        display: flex;
        justify-content: center;
      }
}
</style>
